import React, { Component, createRef } from "react";

export default class UseRefs extends Component {
  // 创建容器
  inputEle = createRef();

  handleClick = () => {
    // 使用容器
    const inputElement = this.inputEle.current;
    console.log(inputElement);
  };

  render() {
    return (
      <>
        {/* 拿到容器 */}
        <input type="text" ref={this.inputEle} />
        <button onClick={this.handleClick}>点击</button>
      </>
    );
  }
}
